<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul id="list">
        <li>li1
            <ul>
                <li>li11</li>
                <li>li12</li>
                <li>li13</li>
                <li>li14</li>
            </ul>
        </li>
        <li>li2
            <ul>
                <li>li21</li>
                <li>li22</li>
                <li>li23</li>
            </ul>
        </li>
        <li>li3</li>
    </ul>
    <script>
        const list = document.getElementById('list');


        function stat(ulist) {
            const lis = ulist.children;
            [...lis].forEach((el) => {
                if (el.children.length !== 0) {
                    const len = el.children[0].children.length;
                    el.childNodes[0].data += `(${len})`;
                }
            })
        }

        stat(list)

    </script>
</body>

</html>